<?php
declare(strict_types=1);

namespace think\admin\test\model;

use think\admin\Model;
use think\model\relation\BelongsToMany;

class Role extends Model
{
    /**
     * 数据表名称
     * @var string
     */
    protected $table = 'role';

    /**
     * 允许写入的字段
     * @var array
     */
    protected $allowField = ['name', 'code', 'description', 'status'];

    /**
     * 获取角色用户关联
     * @return BelongsToMany
     */
    public function users(): BelongsToMany
    {
        return $this->belongsToMany(User::class, 'user_role', 'role_id', 'user_id');
    }
} 